// @/views/goods/mockData.js
export const mockGoodsList = (params) => {
    console.log('请求参数:', params)
    
    // 模拟数据
    const mockData = {
      '1-1': Array(48).fill().map((_, i) => ({
        id: `phone-${i}`,
        title: `闲置智能手机 ${i+1} iPhone/华为/小米等品牌`,
        coverImage: 'https://via.placeholder.com/300x300?text=Phone',
        images: [
          'https://via.placeholder.com/300x300?text=Phone+1',
          'https://via.placeholder.com/300x300?text=Phone+2'
        ],
        price: Math.floor(Math.random() * 5000) + 1000,
        originalPrice: Math.floor(Math.random() * 6000) + 2000,
        isNew: Math.random() > 0.5,
        location: ['北京', '上海', '广州', '深圳', '杭州', '成都'][Math.floor(Math.random() * 6)],
        createTime: Date.now() - Math.floor(Math.random() * 30 * 24 * 3600 * 1000),
        likes: Math.floor(Math.random() * 100),
        views: Math.floor(Math.random() * 500)
      })),
      '1-2': Array(36).fill().map((_, i) => ({
        id: `laptop-${i}`,
        title: `二手笔记本电脑 ${i+1} MacBook/ThinkPad/戴尔等`,
        coverImage: 'https://via.placeholder.com/300x300?text=Laptop',
        images: [
          'https://via.placeholder.com/300x300?text=Laptop+1',
          'https://via.placeholder.com/300x300?text=Laptop+2'
        ],
        price: Math.floor(Math.random() * 8000) + 2000,
        originalPrice: Math.floor(Math.random() * 10000) + 3000,
        isNew: Math.random() > 0.3,
        location: ['北京', '上海', '广州', '深圳', '杭州', '成都'][Math.floor(Math.random() * 6)],
        createTime: Date.now() - Math.floor(Math.random() * 30 * 24 * 3600 * 1000),
        likes: Math.floor(Math.random() * 100),
        views: Math.floor(Math.random() * 500)
      }))
    }
    
    const data = mockData[params.subCategoryId] || mockData['1-1']
    
    // 模拟分页
    const start = (params.page - 1) * params.pageSize
    const end = start + params.pageSize
    const paginatedData = data.slice(start, end)
    
    // 模拟搜索
    const searchedData = params.search 
      ? paginatedData.filter(item => item.title.includes(params.search))
      : paginatedData
    
    // 模拟排序
    let sortedData = [...searchedData]
    switch(params.sort) {
      case 'price_asc':
        sortedData.sort((a, b) => a.price - b.price)
        break
      case 'price_desc':
        sortedData.sort((a, b) => b.price - a.price)
        break
      case 'newest':
        sortedData.sort((a, b) => b.createTime - a.createTime)
        break
      case 'popular':
        sortedData.sort((a, b) => b.views - a.views)
        break
      default:
        // 默认排序
        break
    }
    
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          list: sortedData,
          total: data.length
        })
      }, 300)
    })
  }